saveBitmapToFile

fun saveBitmapToFile(    context: Context,     bitmap: Bitmap,     fileName: String? = null,     path: String? = null,     format: Bitmap.CompressFormat = CompressFormat.PNG,     quality: Int = 100): File

Save a bitmap object into image file.

Return

The created file.

Parameters

context

Context.

bitmap

Bitmap to save.

fileName

Filename for the image, if it is null or blank string, a UUID is used for the image file name. If the file name does not contain the file extension, it is automatically added. So it is recommended that it be the file name without the extension.

path

Absolute path to save the image file, if it is null, it is saved in the temp files directory.

format

Format for the image. Default is PNG.

quality

Quality for the image, between 0 and 100. Default is 100.

Throws

If an I/O error occurs.